<?php

class Queries_mainmenuT {
		
	/**
	* SQL query
	*/
	var $sql;
		
	/**
	 * Describe diversos campos del left join de la tabla care_menu_main con la tabla care_menu_sub
	 * donde is_visible=1 o LD_var='LDEDP' o LD_var='LDLogin'
	 * ordenados por el campo sort_nr
	 * jl
	 */
	function select_care_menu_main_menu_sub(){
		$sql="SELECT a.name, a.LD_var AS \"LD_var\",a.url, b.s_main_nr, b.s_name, b.s_LD_var AS \"s_LD_var\", b.s_url, b.s_image,b.s_open_image, b.s_status, "
		."b.s_ebene, b.s_url_ext FROM care_menu_main as a LEFT  JOIN care_menu_sub as b on a.nr=b.s_main_nr "
		."WHERE a.is_visible=1  OR LD_var='LDEDP' OR LD_var='LDLogin'  ORDER BY a.sort_nr, b.s_sort_nr";
		return $sql;
	}

	/**
	 * Describe diversos campos del left join de la tabla care_ward con la tabla care_department
	 * donde w.is_temp_closed=0
	 * ordenados por el campo sort_nr
	 * jl
	 */
	function select_care_ward_care_department(){
		$sql ="SELECT d.id  AS did,   d.name_short  AS  dname,   d.LD_var as \"LD_var\",   w.dept_nr AS dept_nr FROM care_ward AS w  LEFT   JOIN care_department AS d ON d.nr = w.dept_nr   WHERE w.is_temp_closed=0 GROUP BY w.dept_nr,d.id,d.name_short,d.LD_var ORDER by w.dept_nr ";
		return $sql;	
	}
	
	
	/**
	 * Describe diversos campos de la tabla care_ward
	 * donde el numero de departamento es igual al indicado por el parametro de entrada
	 * ordenados por el campo dept_nr
	 * @params $d_id
	 * jl
	 */
	function select_care_ward($d_id){
		$sql="select nr, dept_nr, ward_id, name from care_ward where is_temp_closed=0 and dept_nr=". $d_id . " order by dept_nr";
		return $sql;	
	}
	
	
}
?>
